import requests
import re
import os
from requests.cookies import RequestsCookieJar
import json
from time import sleep
from selenium import webdriver
#实现无可视化界面
from selenium.webdriver.chrome.options import Options
#实现规避检测
from selenium.webdriver import ChromeOptions

# #无可视化
# chrome_options = Options()
# chrome_options.add_argument('--headless')
# chrome_options.add_argument('--disable-gpu')

# #规避检测
# option = ChromeOptions()
# option.add_experimental_option('excludeSwitches', ['enable-automation'])

# #实例化一个浏览器对象()
# path = r'I:\学习相关\python\爬虫\pixiv\chromedriver_win32\chromedriver.exe'
# browser = webdriver.Chrome(executable_path=path,chrome_options=chrome_options,options=option)

# browser.get('https://accounts.pixiv.net/login')

# #输入账号
# user_tag = browser.find_element_by_xpath('//input[@autocomplete="username"]')
# user_tag.send_keys('1085925182@qq.com')

# #输入密码
# pass_tag = browser.find_element_by_xpath('//input[@autocomplete="current-password"]')
# pass_tag.send_keys('ZHONGjie+1.')

# #登录
# browser.find_element_by_xpath('//div[@id="LoginComponent"]/form/button').click()
# sleep(4)

# #获取cookie
# cookies = browser.get_cookies()
# browser.quit()
# with open('pixiv_cookies2.txt', 'w') as f:
#     f.write(str(cookies))

# #读取cookie
# with open('pixiv_cookies2.txt','r') as f:
#     cookies = eval(f.read())

# se = requests.Session()
# #给session设cookie
# for cookie in cookies:
#     se.cookies.set(cookie['name'], cookie['value'])

# url = 'https://www.pixiv.net/bookmark.php?type=user'
# headers = {
#             'authority': 'www.pixiv.net',
#             'referer': 'https://accounts.pixiv.net/login',
#             'origin': 'https://accounts.pixiv.net',
#             'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36'
#             }

# html = se.get(url = url,headers = headers)

# with open('result.html','w',encoding='utf8') as f:
#     f.write(html.text)


#初始化
def start():
    i=1
    while i == 1:
        name = input("请输入新建文件夹名字:")
        isExists=os.path.exists(name)
        if not isExists:
            os.mkdir(name)
            print(name + "创建成功")
            i = 0
        else:
            print("创建失败!已存在同名文件夹!")

start()

# #登录
# def login()

# #获取排行榜涩图链接
# def rank()

# #获取搜索涩图链接
# def search()

# #获取指定画师所有涩图链接
# def user_id()